package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.dataConfig.ResponseStatus;
import com.dongdongshop.dataConfig.dataResult;
import com.dongdongshop.pojo.TbContent;
import com.dongdongshop.pojo.TbSpecification;
import com.dongdongshop.service.ContentService;
import com.dongdongshop.util.PageBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("advert")
public class AdvertController {
    @Reference
    private ContentService contentService;

    @RequestMapping("getImage")
    @ResponseBody
    public dataResult getImage(){
        try {
            List<TbContent> list = contentService.getImage();
            return new dataResult(ResponseStatus.SUCCESS.getIndex(), ResponseStatus.SUCCESS.getName(),list);
        }catch (Exception e){
            return new dataResult(ResponseStatus.SERVER_ERROR.getIndex(),ResponseStatus.SERVER_ERROR.getName());
        }
    }

    @RequestMapping("getToday")
    @ResponseBody
    public dataResult getToday(){
        try {
            List<TbContent> list = contentService.getToday();
            return new dataResult(ResponseStatus.SUCCESS.getIndex(), ResponseStatus.SUCCESS.getName(),list);
        }catch (Exception e){
            return new dataResult(ResponseStatus.SERVER_ERROR.getIndex(),ResponseStatus.SERVER_ERROR.getName());
        }
    }

    @RequestMapping("getLike")
    @ResponseBody
    public dataResult getLike(){
        try {
            List<TbContent> list = contentService.getLike();
            return new dataResult(ResponseStatus.SUCCESS.getIndex(), ResponseStatus.SUCCESS.getName(),list);
        }catch (Exception e){
            return new dataResult(ResponseStatus.SERVER_ERROR.getIndex(),ResponseStatus.SERVER_ERROR.getName());
        }
    }
}
